#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int MINF = 3005;
const double c = 1e-9;
int textt,n,m,tlen,maxv,ans,dlt,cnt,p,fk[MINF];
bool vis[MINF],v[MINF];

struct node {
	int x,v,a;
};
node car[MINF];

struct pxxp {
    double l,r,len;
};
pxxp xis[MINF];

inline double get_deletax(int vm,int vc,int a) {double rt = (vm*vm-vc*vc)/2/a;return rt;}

int main(void) {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
	scanf("%d",&textt);
	while(textt) {
        memset(vis,false,sizeof(vis));
        memset(v,false,sizeof(v));
	    ans=0,dlt=0,cnt=0;
	    p=0;
		scanf("%d%d%d%d",&n,&m,&tlen,&maxv);
		for(int i=1;i<=n;i++) {scanf("%d%d%d",&car[i].x,&car[i].v,&car[i].a);}
		for(int i=1;i<=m;i++) {scanf("%d",&fk[i]);}
		for(int i=1;i<=n;i++) {
            if(car[i].a <= 0 && car[i].v <= maxv) continue;
            if(car[i].a == 0 ) {cnt++;xis[cnt].l = 0,xis[cnt].r = (double)tlen+c;}
            else if(car[i].a > 0) {
                if(car[i].v > maxv) {cnt++;xis[cnt].l = (double)car[i].x ,xis[cnt].r = (double)tlen+c;continue;}
                double xc = get_deletax(maxv,car[i].v,car[i].a);
                if(xc + car[i].x < tlen) {
                    cnt++;
                    xis[cnt].l = (double)(car[i].x+xc)+c,xis[cnt].r = (double)tlen+c;
                }
            }
            else if(car[i].a < 0) {
                double xm = get_deletax(maxv,car[i].v,car[i].a);
                cnt++;
                xis[cnt].l = (double)car[i].x,xis[cnt].r = min((double)((double)car[i].x+xm),(double)tlen);
                if((double)((double)car[i].x+xm) > tlen) xis[cnt].r+=c;
            }
		}
		for(int j=1;j<=m;j++) {
            for(int k=1;k<=cnt;k++) {
                if(xis[k].l <= (double)fk[j] && xis[k].r > (double)fk[j]) {
                    if(vis[k]) {
                        if(!v[j])dlt++;
                        v[j] = true;
                        continue;
                    }
                    vis[k] = true;
                    ans++;
                }
            }
		}
		printf("%d %d\n",ans,dlt);
		textt--;
	}
	return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15
*/
